<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link href="../css/element.css" rel="stylesheet"/>
    <link href="../css/styleindex.css" rel="stylesheet"/>
    <link href="../css/swiper.min.css" rel="stylesheet"/>
    <style>
    .layui-laydate{
      width: 100%!important;
    }.layui-laydate-main{
      width: 100%!important;
    }
    .layui-laydate-content table{
      width: 100%!important;
    }
    </style>
</head>
<body style="background:#EFF0F4;">

  <div class="mui-content">
    <div id="vm" class="x-examok" v-cloak>
      <div class="x-header-g" id="header">
        <a class="x-header-arrow" @click="api.closeWin()"></a>
        <div class="x-header-t">班组检查</div>
      </div>
      <!--  -->
      <div class="x-trtali-box" id="calali" style="margin:1rem"></div>
      <!--  -->
      <div class="x-workforce-tabs swiper-container" style="margin:1rem">
        <div class="swiper-wrapper">
          <div class="swiper-slide x-workforce-items" v-for="(item,index) in formheaderdata" :key="item.id" @click="changetab(index,item.id)" :class="{active:curId==index}">{{item.title}}</div>
        </div>
      </div>
      <!--  -->
      <div class="x-pro-list" v-if="changeone" style="margin:1rem 0;">
        <!-- <div class="x-inc-num">检查人:{{}}</div> -->
        <template>
          <el-table :data="tabledata">
            <el-table-column label="班组名称" width="" fixed>
              <template slot-scope="scope">
                {{scope.row.group}}
              </template>
            </el-table-column>
            <el-table-column label="周清内容" width="">
              <template slot-scope="scope">
                <el-button type="text" size="mini" @click="editfavo(scope.row.group,scope.row.title)">查看</el-button>
              </template>
            </el-table-column>
            <el-table-column label="完成结果" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.is_ok=='0'" size="mini">未确认</div>
                <div v-if="scope.row.is_ok=='1'" size="mini" class="x-text-g">已完成</div>
                <div v-if="scope.row.is_ok=='2'" size="mini" class="x-text-r">未完成</div>
              </template>
            </el-table-column>
            <el-table-column label="追踪人" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.username!=''||scope.row.username">{{scope.row.username}}</div>
                <div v-else>无</div>
              </template>
            </el-table-column>
            <el-table-column label="记录原因" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.content==''&&scope.row.img==''">无</div>
                  <el-button type="text" size="mini" @click="editfavotwo(scope.row.id,scope.row.content,scope.row.img,scope.row.clearid)" v-else>查看</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </div>
      <!--  -->
      <div class="x-pro-list" v-if="changetwo" style="margin:1rem 0;" v-for="(item,index) in tabledatatwo">
        <div class="x-inc-num">班组{{index+1}}</div>
        <template>
          <el-table :data="item.list">
            <el-table-column label="设备名称" width="" fixed>
              <template slot-scope="scope">
                {{scope.row.title}}
              </template>
            </el-table-column>
            <el-table-column label="维养周期" width="">
              <template slot-scope="scope">
                <div class="" v-if="scope.row.type=='1'">周</div>
                <div class="" v-if="scope.row.type=='2'">月</div>
                <div class="" v-if="scope.row.type=='3'">年</div>
              </template>
            </el-table-column>
            <el-table-column label="维养项目" width="">
              <template slot-scope="scope">
                <el-button type="text" size="mini" @click="editfavo(scope.row.title,scope.row.item)">查看</el-button>
              </template>
            </el-table-column>
            <el-table-column label="完成结果" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.is_ok=='0'" size="mini">未确认</div>
                <div v-if="scope.row.is_ok=='1'" size="mini" class="x-text-g">已完成</div>
                <div v-if="scope.row.is_ok=='2'" size="mini" class="x-text-r">未完成</div>
              </template>
            </el-table-column>
            <el-table-column label="追踪人" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.username!=''||scope.row.username">{{scope.row.username}}</div>
                <div v-else>无</div>
              </template>
            </el-table-column>
            <el-table-column label="记录原因" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.content==''&&scope.row.img==''">无</div>
                  <el-button type="text" size="mini" @click="editfavotwo(scope.row.cateid,scope.row.content,scope.row.img,scope.row.id)" v-else>查看</el-button>
              </template>
            </el-table-column>
          </el-table>
        </template>
      </div>
      <!--  -->
      <div class="x-pro-list" v-if="changethree" style="margin:1rem 0;">
        <!-- <div class="x-inc-num">检查人:{{}}</div> -->
        <template>
          <el-table :data="tabledatathree" :height="isheight">
            <!-- <el-table-column label="序号" width="50" type="index"></el-table-column> -->
            <el-table-column width="" v-for="(item,index) in tabletop" :label="item.label" :key="index" :prop="item.property">
              <template slot-scope="scope">
                {{scope.row[scope.column.property]}}
              </template>
            </el-table-column>
            <!-- <el-table-column label="记录要点" width="">
              <template slot-scope="scope">
                <div v-if="scope.row.content==''&&scope.row.img==''">无</div>
                  <el-button type="text" size="mini" @click="editfavotwo(scope.row.id,scope.row.content,scope.row.img,scope.row.clearid)" v-else>查看</el-button>
              </template>
            </el-table-column> -->
          </el-table>
        </template>
      </div>
      <!--  -->
      <el-dialog :title="toasttitle" :visible.sync="edittoast" width="90%" center="true" close-on-click-modal="false" show-close="false">
        <span>{{toastcon}}</span>
      </el-dialog>
      <!--  -->
      <el-dialog title="" :visible.sync="edittoasttwo" width="90%" center="true" close-on-click-modal="false" show-close="false">
        <div class="x-pro-row">
          <!-- <div class="x-pro-label">添加文字：</div> -->
          <div class="x-pro-input">
            <el-input placeholder="请输入" v-model="textvalue" type="textarea" :rows="3" :disabled="isfromindex"></el-input>
          </div>
        </div>
        <div class="x-pro-himg" :style="{'background-image':'url(' +input4+ ')','background-size':'cover','width':'6rem','height':'6rem','border-radius':'0.4rem','margin-top':'1rem'}" v-if="input4!=''" @click="imagebig = true"></div>
      </el-dialog>
      <img :src="input4" alt="" width="100%" v-if="imagebig" class="x-img-big" @click="imagebig = false">
    </div>
  </div>

  <script type="text/javascript" src="../script/vue.js"></script>
  <script type="text/javascript" src="../script/element.js"></script>
  <script type="text/javascript" src="../script/api.js"></script>
  <script type="text/javascript" src="../script/base.js"></script>
  <script type="text/javascript" src="../script/swiper.min.js"></script>
  <script type="text/javascript" src="../script/laydate/laydate.js"></script>
	<script>
apiready = function () {
    $api.fixStatusBar($api.byId('header'));


    //
    var vm = new Vue({
      el:'#vm',
      data(){
        return{
          isfromindex:false,
          thmonth:'',
          formheaderdata:'',
          curId:0,
          tabledata:[],
          tabledatatwo:'',
          tabledatathree:[],
          edittoast:false,
          toasttitle:'',
          toastcon:'',
          edittoasttwo:false,
          textvalue:'',
          input4:'',
          editid:'',
          clearid:'',
          tabsid1:'',
          tabsid2:'',
          tabledataother:[],
          changeone:true,
          changetwo:false,
          changethree:false,
          istype:'week',
          tabletop:'',
          isheight:'',
          imagebig:false
          // tabletop:[
          //     {
          //         'label':'工龄',
          //         'property':'age'
          //     },{
          //         'label':'人数',
          //         'property':'n'
          //     }
          // ],// 表头

        }
      },
      created:function() {
        var that=this;


      },
      mounted:function(){
        var that=this;
        laydate.render({
          elem: '#calali',
          position: 'static',
          btns:['now'],
          format:'yyyyMMdd',
          // theme:'#058142',
          change:function(value,date){
            console.log(value);
            that.thmonth = value;
            if(that.tabsid1 == 'week'){
              that.getdata()
            }else if(that.tabsid1=='clear'){
              that.getcleardata()
            }else{
              that.gettrainadmintwo()
            }

          }
        });
        //当前月份
        var date = new Date();
        var year = date.getFullYear();
        var month = date.getMonth()+1;
        var day = date.getDate()
        if(month<10){
          month = '' + 0 + month;
        }
        if(day<10){
          day = '' + 0 + day;
        }
        var toMonth = '' + year +  month +  day;
        that.thmonth = toMonth;
        that.getdata()
        that.gettrainadmin()

      },
      methods: {
        //列表 other
        gettrainadmin:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/teamcheck/getCheck',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                cateid:that.tabsid1,
                timeid:that.tabsid2,
                date:that.thmonth,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.formheaderdata = ret.data.cate;//tabs1
                  var week = {
                    title:'追踪周清结果',
                    id:'week'
                  }
                  var clear = {
                    title:'追踪设备清洁',
                    id:'clear'
                  }
                  that.formheaderdata.unshift(week,clear);
                  that.tabledataother = ret.data.list;
                  that.tabsid1 = ret.data.cate[0].id;
                  that.tabsid2 = ret.data.time[0].id;
                  var nunum;
                  if(that.formheaderdata.length<3){
                    nunum = 2;
                  }else{
                    nunum = 3;
                  }
                  that.$nextTick(function(){
                    var mySwiper = new Swiper('.swiper-container',{
                      freeMode: true,
                      loop:false,//设置 active slide 居中后，会有左右留白现象，添加此会让未尾的导航补齐前后空白
                      slideToClickedSlide: true,//设置为true则点击slide会过渡到这个slide。
                      slidesPerView: nunum,
                      centeredSlides: false,//设定为true时，active slide会居中，而不是默认状态下的居左。
                      spaceBetween: 10,//slide之间设置距离
                      slidesOffsetBefore: 0,//设定slide与左边框的预设偏移量
                      slidesOffsetAfter: 0,//设定slide与右边框的预设偏移量

                    });

                  });
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //表头 other
        gettrainadmintwo:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/teamcheck/getCheck2',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                cateid:that.tabsid1,
                date:that.thmonth,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.tabletop = ret.data.header;
                  that.tabledatathree = ret.data.list;
                  that.isheight = that.tabledatathree.length*200;
                  console.log(that.tabledatathree.length*200);
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //周清
        getdata:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/teamcheck/getClear',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                  that.tabledata = ret.data.list;
                  console.log(JSON.stringify(that.tabledata));
              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
        //记录要点
        editfavo:function(title,content){
          var that = this;
          that.toasttitle = title;
          that.toastcon = content;
          that.edittoast = true;
        },
        //记录要点2,3
        editfavotwo:function(id,con,img,clearid){
          var that = this;
          that.textvalue = con;
          that.input4 = img;
          that.editid = id;
          that.clearid = clearid;
          that.edittoasttwo = true;

        },
        //tabs 切换
        changetab:function(index,id){
          var that = this;
          console.log(id);
          that.curId = index;
          that.tabsid1 = id;
          if(id=='week'){
            that.changeone = true;
            that.changetwo = false;
            that.changethree = false;
          }else if(id=='clear'){
            that.changeone = false;
            that.changetwo = true;
            that.changethree = false;
            that.getcleardata()
          }else{
            that.gettrainadmintwo()
            that.changeone = false;
            that.changetwo = false;
            that.changethree = true;
          }

        },
        //设备清洁 data
        getcleardata:function(){
          let that=this;
          api.ajax({
            url:baseurl+'api/teamcheck/device',
            methods:'get',
            data:{
              values:{
                sec: $api.getStorage('apptoken'),
                date:that.thmonth,
                _ssid:$api.getStorage('jobid')
              }
            }
          },function(ret,err){
            if(ret){
              api.hideProgress();
              console.log(JSON.stringify(ret));
              if(ret.status == 1){
                that.tabledatatwo = ret.data.list;

              }else{
                api.toast({
                    msg: ret.msg,
                    duration: 3000,
                    location: 'bottom'
                });
              }
            }else{
              api.hideProgress();
              console.log(JSON.stringify(err));
              api.toast({
                  msg: err.msg,
                  duration: 3000,
                  location: 'bottom'
              });
            }
          })
        },
      }
    })
	}


	</script>
</body>
</html>
